home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / program / rcs5ap1s.lzh / RCSKEYS.C < prev    next >
C/C++ Source or Header  |  1991-01-30  |  3KB  |  102 lines

  1. /*
  2.  *                     RCS keyword table and match operation
  3.  */
  4.  
  5. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  6.    Copyright 1990 by Paul Eggert
  7.    Distributed under license by the Free Software Foundation, Inc.
  8.  
  9. This file is part of RCS.
  10.  
  11. RCS is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 1, or (at your option)
  14. any later version.
  15.  
  16. RCS is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with RCS; see the file COPYING.  If not, write to
  23. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25. Report problems and direct all questions to:
  26.  
  27.     rcs-bugs@cs.purdue.edu
  28.  
  29. */
  30.  
  31.  
  32.  
  33. /* $Log: rcskeys.c,v $
  34.  * Revision 5.1  1991/01/30  14:21:32  apratt
  35.  * CI with RCS version 5
  36.  *
  37.  * Revision 5.0  90/08/22  08:12:54  eggert
  38.  * checked in with -k by apratt at 91.01.10.13.15.22.
  39.  * 
  40.  * Revision 5.0  1990/08/22  08:12:54  eggert
  41.  * Add -k.  Ansify and Posixate.
  42.  *
  43.  * Revision 4.3  89/05/01  15:13:02  narten
  44.  * changed copyright header to reflect current distribution rules
  45.  * 
  46.  * Revision 4.2  87/10/18  10:36:33  narten
  47.  * Updating version numbers. Changes relative to 1.1 actuallyt
  48.  * relative to 4.1
  49.  * 
  50.  * Revision 1.2  87/09/24  14:00:10  narten
  51.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  52.  * warnings)
  53.  * 
  54.  * Revision 4.1  83/05/04  10:06:53  wft
  55.  * Initial revision.
  56.  * 
  57.  */
  58.  
  59.  
  60. #include "rcsbase.h"
  61.  
  62. libId(keysId, "$Id: rcskeys.c,v 5.1 1991/01/30 14:21:32 apratt Exp $")
  63.  
  64.  
  65. const char *const Keyword[] = {
  66.     /* This must be in the same order as rcsbase.h's enum markers type. */
  67.     nil,
  68.     AUTHOR, DATE, HEADER, IDH,
  69.     LOCKER, LOG, RCSFILE, REVISION, SOURCE, STATE,
  70. };
  71.  
  72.  
  73.  
  74.     enum markers
  75. trymatch(string)
  76.     const char *string;
  77. /* function: Checks whether string starts with a keyword followed
  78.  * by a KDELIM or a VDELIM.
  79.  * If successful, returns the appropriate marker, otherwise Nomatch.
  80.  */
  81. {
  82.         register int j;
  83.     register const char *p, *s;
  84.     for (j = sizeof(Keyword)/sizeof(*Keyword);  (--j);  ) {
  85.         /* try next keyword */
  86.         p = Keyword[j];
  87.         s = string;
  88.         while (*p++ == *s++) {
  89.             if (!*p)
  90.                 switch (*s) {
  91.                 case KDELIM:
  92.                 case VDELIM:
  93.                     return (enum markers)j;
  94.                 default:
  95.                     return Nomatch;
  96.                 }
  97.         }
  98.         }
  99.         return(Nomatch);
  100. }
  101.  
  102.